package com.lilihub.miaosha.service;

import com.lilihub.miaosha.dao.UserDao;
import com.lilihub.miaosha.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @BelongsProject: miaosha
 * @BelongsPackage: com.lilihub.miaosha.service
 * @Author: LiYing
 * @CreateTime: 2021-04-22 10:32
 * @Description:
 */
@Service
public class UserService {


    @Autowired
    private UserDao userDao;

    public User getById(int id){

        return userDao.getById(id);


    }


    @Transactional
    public boolean tx() {

        User u1 = new User();
        u1.setId(2);
        u1.setName("2222222");

        User u2 = new User();
        u2.setId(1);
        u2.setName("333333");

        userDao.insert(u1);
        userDao.insert(u2);

        return true;

    }
}
